package com.tryine.soudafu.healty.exception;

import com.tryine.common.resp.BaseResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理
 * @author ludans
 * @program soudafu-healty-controller
 * @date 2020/7/16 13:47
 */
@Slf4j
@ControllerAdvice(basePackages = "com.tryine.soudafu.healty.controller")
public class AppExceptionHandler {

    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public BaseResp handIllegalArgumentException(IllegalArgumentException e){
        log.error("参数校验错误",e);
        return BaseResp.fail(e.getMessage());
    }

}
